from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from time import sleep
from options import options

#操作键盘鼠标实现滚动条

driver = webdriver.Chrome(options=options)
driver.get(r'https://www.jd.com/')

# 比较复杂，不怎么用
# # 设置滚动条距离顶部的位置，设置为 10000（最底部）
# js_down = 'var action=document.documentElement.scrollTop=10000'
# driver.execute_script(js_down)
# sleep(5)
#
# # 设置滚动条距离顶部的位置，设置为 10000（最顶部）
# js_up = 'var action=document.documentElement.scrollTop=0'
# driver.execute_script(js_up)
# sleep(5)


# 常用的js代码
# # 向下滚动
# js_down = 'window.scrollTo(0,1000)'
# driver.execute_script(js_down)
# sleep(3)
# # 向上滚动
# js_up = "window.scrollTo(0,0)"
# driver.execute_script(js_up)
# sleep(3)

#向右滚动
js_right = "window.scrollTo(1000,0)"
driver.execute_script(js_right)
sleep(3)

# 向左滚动
js_left = "window.scrollTo(0,0)"
driver.execute_script(js_left)
sleep(3)
